@extends('admin.default')
@section('title', '网站设置')
@section('content')
    <div class="x-nav">

        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">网站设置</div>
                    <div class="layui-card-body" >
                        <form class="layui-form" action="" lay-filter="component-form-group">
                        <div class="layui-form-item">
                            <label class="layui-form-label">网站名称：</label>
                            <div class="layui-col-md6" >
                                <input type="text" name="name" value="{{$data->name}}" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">网站域名：</label>
                            <div class="  layui-col-md6" >
                                <input type="text" name="url" value="{{$data->url}}" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                <span class="x-red">*</span>域名以http://或https://开头
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">网站logo：</label>
                            <div class="layui-col-md6" >
                                <input type="text" name="logo" value="{{$data->logo}}" class="layui-input">
                            </div>
                            <div class="layui-upload">
                                <button type="button" class="layui-btn layui-btn-normal" id="test-upload-change">选择文件</button>
                                <button type="button" class="layui-btn" id="test-upload-change-action">开始上传</button>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">网站备案号：</label>
                            <div class="layui-col-md6" >
                                <input type="text" name="icp" value="{{$data->icp}}" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">网站开关：</label>
                            <div class="layui-col-md6" >

                                <input type="radio" name="status" value="1" title="开" {{$data->status==1 ? 'checked' : ''}}>
                                <input type="radio" name="status" value="2" title="关" {{$data->status==2 ? 'checked' : ''}}>
                            </div>
                        </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label"><span class="x-red">SEO优化设置</span></label>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">页面Title：</label>
                                <div class="layui-col-md6" >
                                    <input type="text" name="title" value="{{$data->title}}" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">Keywords：</label>
                                <div class="layui-col-md6" >
                                    <input type="text" name="keywords" value="{{$data->keywords}}" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">Description：</label>
                                <div class="layui-col-md6" >
                                    <textarea  id="desc" name="desc" class="layui-textarea">{{$data->desc}}</textarea>
                                </div>
                            </div>
                            {{csrf_field()}}
                            <div class="layui-form-item">
                                <label for="L_repass" class="layui-form-label"></label>
                                <button class="layui-btn" lay-filter="update" lay-submit="">修改</button></div>
                        </form>

                    </div>

                </div>
            </div>



        </div>
    </div>
    <script>layui.use(['form', 'layer'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                    layer = layui.layer;
                form.on('submit(update)',
                    function(data) {
                        data = data.field;
                        console.log(data);
                        $.ajax({
                            type: 'POST',
                            url: '{{route('admin.config.update')}}',
                            data: data,
                            dataType: 'json',
                            success: function (data){
                                if(data == 1){
                                    layer.alert('修改成功', {
                                        icon: 1,
                                        skin: 'layui-layer-molv' //样式类名
                                        ,closeBtn: 0
                                    }, function(){
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                        parent.location.reload();
                                    });
                                } else{
                                    layer.alert('修改失敗', {
                                        icon: 2,
                                        skin: 'layui-layer-molv' //样式类名
                                        ,closeBtn: 0
                                    });
                                }
                            },
                            error: function(res){
                                var msg=JSON.parse(res.responseText);
                                layer.alert(msg.message, {
                                    icon: 2,
                                    title: '提示信息',
                                    skin: 'layui-layer-molv' //样式类名
                                    ,closeBtn: 0
                                });
                            }
                        });

                        return false;
                    });
            });
    </script>
@stop
